#!/usr/bin/env php
<?php
// Require Doctrine.php then Set the autoloader
require_once('../../vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));

// mockup that this app was executed from ci ;)
define('BASEPATH', '.');
chdir(dirname(__FILE__));

// Create dsn from the info above
$db = array('dsn' => 'mysql://root:@localhost/max;');

// Load the Doctrine connection
$conn = Doctrine_Manager::connection($db['dsn'], 'doctrine');


// Configure Doctrine Cli
$config = array('yaml_schema_path' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'schema');

$cli = new Doctrine_Cli($config);

if (!strcmp($_SERVER['argv'][1], "ParseYml"))
{

//    $refrenceClasses = array('RoleTask','ItemUsers','UserCamera');
    $refrenceClasses = array(
        array('Product', 'User'),
    );

    require_once('YamlParser.php');
    $_yamlTest = new YamlParser();
    //$_softDeleteArray = array('Company');
    $_yamlTest->parseFile($config['yaml_schema_path'] . "/schema.yml");
    $_yamlTest->addManyToManyRelations($refrenceClasses);
    $_yamlTest->dumpTofile("test.yml");
    printf("done\n");
    return 0;
}


$cli->run($_SERVER['argv']);